#ifndef JLIB_BITS_BITMAP_H
#define JLIB_BITS_BITMAP_H

#include "asm.h"

namespace jlib {


template<unsigned int Max>
struct bitmap {

  inline bool test (unsigned int idx) const noexcept { return bit_test(this->_bits, idx); }
  inline bool tsts (unsigned int idx) noexcept { return bit_test_and_set(this->_bits, idx); }
  inline bool tstr (unsigned int idx) noexcept { return bit_test_and_reset(this->_bits, idx); }
  inline bool tstc (unsigned int idx) noexcept { return bit_test_and_complement(this->_bits, idx); }
  inline void zero () noexcept { memset(this->_bits, 0, sizeof(this->_bits)); }

private:
  unsigned char _bits[(Max + 7) / 8];
};


} // namespace jlib

#endif // JLIB_BITS_BITMAP_H
